package week2.mapreduce;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

import java.io.IOException;

public class flowmr {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        //建立连接
        Configuration configuration = new Configuration(true);
        Job job = Job.getInstance(configuration);
        job.setJarByClass(flowmr.class);
        job.setJobName("flowMR");
        //输入输出路径
        Path intputpath = new Path(args[0]);
        TextInputFormat.addInputPath(job, intputpath);
        Path outputpath = new Path(args[1]);
        TextOutputFormat.setOutputPath(job, outputpath);
        //MR函数
        job.setMapperClass(FlowMapper.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(bean.class);
        job.setReducerClass(FlowReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(bean.class);
        job.waitForCompletion(true);
    }
}
